package com.freshmarket.freshmarket.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freshmarket.freshmarket.entity.Coupon;
import com.freshmarket.freshmarket.dao.CouponMapper;
import com.freshmarket.freshmarket.service.ICouponService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Squirrel
 * @since 2020-09-04
 */
@Service
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements ICouponService {
@Autowired
private CouponMapper couponMapper;
    @Override
    public IPage<Coupon> selectCoupon(int pageIndex, int pageSize, String couponStatus,String couponDiscountsStatus) {
        Page<Object> objectPage = new Page<>(pageIndex, pageSize);
        IPage<Coupon> coupons = couponMapper.queryCoupon(objectPage, couponStatus,couponDiscountsStatus);

        return coupons;
    }

    @Override
    public IPage<Coupon> selectCouponAll(int pageIndex, int pageSize) {
        Page<Object> objectPage = new Page<>(pageIndex, pageSize);
        IPage<Coupon> couponIPage = couponMapper.queryCouponAll(objectPage);
        return couponIPage;
    }
}
